package com.mbc.mapper;


import com.mbc.dto.MbcBlackListInfoDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 黑名单表 Mapper 接口
 * </p>
 *
 * @author suimeng
 * @since 2024-04-15
 */

@Mapper
public interface BlackListInfoMapper {

    /**
     * 查询用户被举报人id
     *
     * @param reasonsId 原因 ID
     * @return int
     */
    @Select("select count(user_id) from mbc_black_list_info where user_id = #{reasonsId}")
    int getByUserId(Integer reasonsId);

    /**
     * 新增被举报人详细信息
     *
     * @param reasonsId           被举报人 ID
     * @param mbcBlackListInfoDTO MBC黑名单信息DTO
     * @return int
     */
    @Insert("insert into mbc_black_list_info(user_id, sex, name, nickname, phone_number, wechat_number, city, " +
            "address) " +
            "values (#{reasonsId},#{mbcBlackListInfoDTO.sex},#{mbcBlackListInfoDTO.name},#{mbcBlackListInfoDTO" +
            ".nickname},#{mbcBlackListInfoDTO.phoneNumber},#{mbcBlackListInfoDTO.wechatNumber},#{mbcBlackListInfoDTO" +
            ".city},#{mbcBlackListInfoDTO.address})")
    int insertInfoBlackUser(Integer reasonsId, MbcBlackListInfoDTO mbcBlackListInfoDTO);

    /**
     * 更新被举报人信息
     *
     * @param reasonsId    被举报人 ID
     * @param sex          性
     * @param name         名字
     * @param nickname     昵称
     * @param phoneNumber  电话号码
     * @param wechatNumber 微信号
     * @param city         城市
     * @param address      地址
     * @return int
     */
    @Update("update mbc_black_list_info set sex =#{sex},name =#{name},nickname=#{nickname}," +
            "phone_number=#{phoneNumber},wechat_number=#{wechatNumber},city=#{city},address=#{address} where user_id " +
            "= #{reasonsId}")
    int updateBlackInfoUser(Integer reasonsId, String sex, String name, String nickname, String phoneNumber,
                            String wechatNumber, String city, String address);
}
